////////////////////////////////////////////////////////////////////////////////
// Copyright 2006 CORE Solutions Limited
// All rights reserved.
// PROPRIETARY AND CONFIDENTIAL INFORMATION.
// Use is subject to license terms.
//
// FUNCTION ID      :   ITEM_CLASS
// AUTHOR           :   Alex Cheung 
// DATE CREATE      :   2006/01/20
// DESCRIPTION      :   a BIZ LOGIC file for the function, ITEM_CLASS
//                  :   
//                  :   
//                  :   
//
// MODIFICATION HISTORY:
// DATE         AUTHOR          VERSION NO.         COMMENT
// -----------  --------------  ------------------  -------------------
// 2006/01/20   Alex Cheung     1.0                 source is generated.
//
//
//
////////////////////////////////////////////////////////////////////////////////

package com.erp.app.catalog.itemClass.bizLogic;

import java.sql.Connection;

import com.erp.app.catalog.itemClass.dao.ItemClassCommonDao;
import com.erp.framework.model.bizLogic.SimplePageEditStyleBizLogic;
import com.erp.framework.model.vo.SimpleBaseVo;
import com.erp.framework.util.logger.Logger;

/**
* <p>A <strong>BizLogic</strong> provides the logical flow and control
* of the business model at different transaction time.
*
* @author          Alex Cheung 
* @version 1.0     2006/01/20
* @since           FrameWork 1.0
*
*/
public class ItemClassBizLogic extends SimplePageEditStyleBizLogic {

	ItemClassCommonDao dao = new ItemClassCommonDao();
	
	/**
	* Generates a unique document number.
	*
	* @param      model   the incoming business model (VO)
	* @param      conn    the database connection
	*
	* @author     Alex Cheung 
	* @since      FrameWork 1.0
	*/
	/**
	* Provides logics to insert business object before creating the object.
	* Note that this function has NO user transaction control.
	*
	* @param      model   the incoming business model (VO)
	*
	* @author     Alex Cheung 
	* @since      FrameWork 1.0
	*/
	public void bizLogicsBeforeCreate(SimpleBaseVo model) throws Exception {
		Logger.debug(this, "in bizLogicsBeforeCreate()");
	}

	/**
	* Provides logics to insert business object before creating the object.
	* Note that this function has user transaction control.
	*
	* @param      model   the incoming business model (VO)
	* @param      conn    the database connection
	*
	* @author     Alex Cheung 
	* @since      FrameWork 1.0
	*/
	public void bizLogicsBeforeCreateModel(SimpleBaseVo model, Connection conn) throws Exception {
        dao.insertRelateTables(model, conn);
		Logger.debug(this, "in bizLogicsBeforeCreateModel()");
		setPkForNonStandardChildren(model);
	}

	/**
	* Provides logics to insert business object after creating the object.
	* Note that this function has user transaction control.
	*
	* @param      model   the incoming business model (VO)
	* @param      conn    the database connection
	*
	* @author     Alex Cheung 
	* @since      FrameWork 1.0
	*/
	public void bizLogicsAfterCreateModel(SimpleBaseVo model, Connection conn) throws Exception {

//		dao.updateMasterRecord(model, conn);
	}
	
	/**
	* Provides logics to insert business object after creating the object.
	* Note that this function has NO user transaction control.
	*
	* @param      model   the incoming business model (VO)
	*
	* @author     Alex Cheung 
	* @since      FrameWork 1.0
	*/
	public void bizLogicsAfterCreate(SimpleBaseVo model) throws Exception {

		Logger.debug(this, "in bizLogicsAfterCreate()");
	}

	/**
	* Provides logics to update business object before updating the object.
	* Note that this function has NO user transaction control.
	*
	* @param      model   the incoming business model (VO)
	*
	* @author     Alex Cheung 
	* @since      FrameWork 1.0
	*/
	public void bizLogicsBeforeUpdate(SimpleBaseVo model) throws Exception {

		Logger.debug(this, "in bizLogicsBeforeUpdate()");
	}
	
	/**
	* Provides logics to update business object before updating the object.
	* Note that this function has user transaction control.
	*
	* @param      model   the incoming business model (VO)
	* @param      conn    the database connection
	*
	* @author     Alex Cheung 
	* @since      FrameWork 1.0
	*/
	public void bizLogicsBeforeUpdateModel(SimpleBaseVo model, Connection conn) throws Exception {

		Logger.debug(this, "in bizLogicsBeforeUpdateModel()");
		setPkForNonStandardChildren(model);
	}

	/**
	* Provides logics to update business object after updating the object.
	* Note that this function has user transaction control.
	*
	* @param      model   the incoming business model (VO)
	* @param      conn    the database connection
	*
	* @author     Alex Cheung 
	* @since      FrameWork 1.0
	*/
	public void bizLogicsAfterUpdateModel(SimpleBaseVo model, Connection conn) throws Exception {

//		dao.updateMasterRecord(model, conn);
	}

	/**
	* Provides logics to update business object after updating the object.
	* Note that this function has NO user transaction control.
	*
	* @param      model   the incoming business model (VO)
	*
	* @author     Alex Cheung 
	* @since      FrameWork 1.0
	*/
	public void bizLogicsAfterUpdate(SimpleBaseVo model) throws Exception {

		Logger.debug(this, "in bizLogicsAfterUpdate()");
	}
	
	/**
	* Provides logics to remove business object before removing the object.
	* Note that this function has NO user transaction control.
	*
	* @param      model   the incoming business model (VO)
	*
	* @author     Alex Cheung 
	* @since      FrameWork 1.0
	*/
	public void bizLogicsBeforeRemove(SimpleBaseVo model) throws Exception {
        
		Logger.debug(this, "in bizLogicsBeforeRemove()");
	}
	
	/**
	* Provides logics to remove business object before removing the object.
	* Note that this function has user transaction control.
	*
	* @param      model   the incoming business model (VO)
	* @param      conn    the database connection
	*
	* @author     Alex Cheung 
	* @since      FrameWork 1.0
	*/
	public void bizLogicsBeforeRemoveModel(SimpleBaseVo model, Connection conn) throws Exception {
		dao.removeRelateTables(model, conn);
		Logger.debug(this, "in bizLogicsBeforeRemoveModel()");
	}

	/**
	* Provides logics to remove business object after removing the object.
	* Note that this function has user transaction control.
	*
	* @param      model   the incoming business model (VO)
	* @param      conn    the database connection
	*
	* @author     Alex Cheung 
	* @since      FrameWork 1.0
	*/
	public void bizLogicsAfterRemoveModel(SimpleBaseVo model, Connection conn) throws Exception {

//		dao.updateMasterRecord(model, conn);
	}
	/**
	* Provides logics to remove business object after removing the object.
	* Note that this function has NO user transaction control.
	*
	* @param      model   the incoming business model (VO)
	*
	* @author     Alex Cheung 
	* @since      FrameWork 1.0
	*/
	public void bizLogicsAfterRemove(SimpleBaseVo model) throws Exception {

		Logger.debug(this, "in bizLogicsAfterRemove()");
	}
	
	/**
	* Sets the primary key for non-standard or shared children, such as Item Task
	* @param      model   the incoming business model (VO)
	*
	* @author     Alex Cheung 
	* @since      FrameWork 1.0
	*/
	public void setPkForNonStandardChildren(SimpleBaseVo model) {

//		SoHdrVo vo = (SoHdrVo) model;
//		ChildList dtlList = vo.getChilds(ItemTaskVo.class);

//		if (dtlList != null && dtlList.size() > 0) {
//			for (int i=0; i<dtlList.size(); i++) {
//				ItemTaskVo dtlVo = (ItemTaskVo) dtlList.get(i);
//				if (CommonUtil.isEmpty(dtlVo.getDocumentNo())) {
//					dtlVo.setCompanyCode(vo.getCompanyCode());
//					dtlVo.setDocumentNo(vo.getSoNo());
//				}
//			}
//		}
	}
}
